const paginationBev = Behavior({
    data: {
        dataArray: [],
        total:null,
        noneResult:false,
        locking:false,//锁，避免下拉加载被多次调用
    },
    methods: {
        setMoreData(dataArray){
            const tempArray = this.data.dataArray.concat(dataArray);
            this.setData({
                dataArray:tempArray,
            });
        },
        getCurrentStart(){
            return this.data.dataArray.length;
        },
        setTotal(total){
            this.data.total = total;
            if(total == 0){
                this.setData({
                    noneResult:true,
                });
            }
        },
        hasMore(){
            if(this.data.dataArray.length >= this.data.total){
                return false;
            }else{
                return true;
            }
        },
        initialize(){
            this.setData({
                dataArray: [],
                noneResult:false,
                locking:false,
            });
            this.data.total = null;
        },
        //将锁锁上
        locked(){
            this.setData({
                locking: true,
            });
        },
        //将锁打开
        unlock(){
            this.setData({
                locking: false,
            });
        },
        //判断是否加锁
        isLocked(){
            return this.data.locking;
        }


    }
});

export {paginationBev}